<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2005/06/18 21:38:31 $)
// $RCSfile: visitor_emailimage.php,v $ : $Revision: 1.4 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

$template->loadLanguageSection("livesupportclient");


/**
* ###############################################
* Redirect to the chat window
* ###############################################
*/
if ($eventaction == "emailchat")
{
	// Does this user have a session id set?
	$cookiesessionid = $cookie->getSCookie("sessionid".SESSION_VISITOR);
	if (trim($cookiesessionid) == "")
	{
		$sessionid = $session->insertSession(SESSION_VISITOR);
	} else {
		$sessionid = $cookiesessionid;
	}

	header("location: ".$_SWIFT["swiftpath"]."visitor/index.php?_m=livesupport&_a=startclientchat&sessionid=".$sessionid."&proactive=0&departmentid=".$_GET["departmentid"]);



/**
* ###############################################
* Spit out the Online/Offline Image
* ###############################################
*/
} else if ($eventaction == "emailimage") {
	require_once ("./modules/livesupport/functions_livesupport.php");
	
	headerNoCache();
	header("Content-Type: image/gif");

	$staffstatus = isStaffMonitorOnline($_GET["departmentid"]);
	if ($staffstatus == STATUS_ONLINE)
	{
		readfile($_SWIFT["themepath"]."staffonline.gif");
	} else if ($staffstatus == STATUS_AWAY) {
		readfile($_SWIFT["themepath"]."staffaway.gif");
	} else if ($staffstatus == STATUS_BACK) {
		readfile($_SWIFT["themepath"]."staffbackin5.gif");
	} else {
		readfile($_SWIFT["themepath"]."staffoffline.gif");
	}
}

?>